package com.fyy.shardingjdbc.service.impl;

import com.fyy.shardingjdbc.dao.ProductDao;
import com.fyy.shardingjdbc.model.ProductDescript;
import com.fyy.shardingjdbc.model.ProductInfo;
import com.fyy.shardingjdbc.service.IProductService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProductServiceImpl implements IProductService {

    @Resource
    private ProductDao productDao;

    @Override
    public int insertProduct(ProductInfo info) {
        ProductDescript descript = new ProductDescript();
        descript.setMiaoshu(info.getMiaoshu());
        productDao.insertProduct(info);
        descript.setProductId(info.getId());
        descript.setStoreId(info.getStoreId());
        productDao.insertProductDes(descript);
        return 0;
    }

    @Override
    public List<ProductInfo> queryProduct(Integer start, Integer pageSize) {
        return productDao.queryProduct(start,pageSize);
    }

    @Override
    public int getProductTotal() {
        return productDao.getProductTotal();
    }

    @Override
    public List<ProductInfo> queryProduct() {
        return productDao.queryProduct();
    }


}
